package com.uni.action;

import com.uni.entity.Commodity;
import com.uni.entity.User;
import com.uni.service.Service;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import java.io.IOException;
import java.util.List;

/**
 * --------------project-------------
 *
 * @Author Unirithe  - Mr.Chao
 * - CSDN:
 * https://blog.csdn.net/Unirithe
 * - GitHub:
 * https://github.com/unirithe
 * @create 2021/12/24 15:00
 * ------------------------------------------
 */

@WebServlet(name = "PublishQueryAction", urlPatterns = "/queryPublish")
public class PublishQueryAction extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        HttpSession session = req.getSession();
        User user = (User) session.getAttribute("userInfo");
        List<Commodity> commodities = Service.commodity.queryByUid(user.getId());
        session.setAttribute("publishInfo", commodities);
        resp.sendRedirect("card_user_publish_commodity.jsp");
    }
}
